package client.comm.baoding.adapter.main

import android.content.Context
import android.content.Intent
import android.graphics.Color
import android.text.Layout
import android.view.View
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.recyclerview.widget.RecyclerView
import client.comm.baoding.R
import client.comm.baoding.api.bean.AssetsRecode
import client.comm.baoding.api.bean.AssetsRecode2
import client.comm.baoding.databinding.ItemMyAssetBinding
import client.comm.commlib.base.BaseLoadmoreAdapter
import client.comm.commlib.base.BindingViewHoder
import com.bumptech.glide.RequestManager

class MyZcAdapter : BaseLoadmoreAdapter<AssetsRecode2.MyGoodsInfo> {

    val manager: RequestManager

    constructor(context: Context, manager: RequestManager) : super(context) {
        this.manager = manager
    }

    override fun createVh(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
        return BindingViewHoder(
            DataBindingUtil.inflate(
                layoutInflater,
                R.layout.item_my_asset,
                parent,
                false
            )
        )
    }

    override fun bindVh(holder: RecyclerView.ViewHolder, position: Int) {
        val bindingViewHolder = holder as BindingViewHoder<ViewDataBinding>
        val binding = bindingViewHolder.binding as ItemMyAssetBinding
        val bean = getItem(position)
        binding.bean = bean
        binding.event = this

        manager.load(bean.goods_image).error(R.mipmap.ic_launcher).into(binding.ivGood)

    }

    var itemClick: ((bean: AssetsRecode2.MyGoodsInfo) -> Unit)? = null
    var tihuo: ((bean: AssetsRecode2.MyGoodsInfo) -> Unit)? = null
    var tuikuan: ((bean: AssetsRecode2.MyGoodsInfo) -> Unit)? = null

    //商品详情12
    fun itemClick(bean: AssetsRecode2.MyGoodsInfo) {
        itemClick?.invoke(bean)
    }

    //提示暂未开放
    fun tihuo() {

    }

    fun onTihuo(bean: AssetsRecode2.MyGoodsInfo) {
        tihuo?.invoke(bean)
    }

    fun onTuiKuan(bean: AssetsRecode2.MyGoodsInfo) {
        tuikuan?.invoke(bean)
    }


}